// pages/reserve/index/index.js
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        setting:null,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getSetting();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {
        
    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    return {
      title: '青岛市特种设备安全智慧体验中心',
      path: '/pages/reserve/index/index',
      success: function (res) {
        wx.showToast({
          title: '已转发',
          icon: 'success',
          duration: 2000
        })
      }
    }
  },
    getSetting(){
        const that = this;
        wx.request({
          url: app.globalData.apiUrl + 'api/scansence/getSetting',
          method: 'GET',
          data: {
            
          },
          header: {
            'Content-Type': 'application/json'
          },
          success: function (res) {
            console.log(res.data)
            if(res.data){
              that.setData({
                setting:res.data.setting
              })
            }
            
            
          },
          fail: function () {
            
          },
          complete: function () {
          }
        })
      },
    navgateNotice1(){
        let src = this.data.setting.announce_url;
        wx.navigateTo({
          url: '/pages/reserve/notice/index?src='+encodeURIComponent(src),
        }) 
    },
    navgateNotice2(){
        let src = this.data.setting.notice_url;
        wx.navigateTo({
          url: '/pages/reserve/notice/index?src='+encodeURIComponent(src),
        }) 
    },
    reservePersonal(){
      if(!this.data.setting.personal) return ;
        wx.navigateTo({
          url: '/pages/reserve/personal/index',
        })
    },
    reserveTeam(){
      if(!this.data.setting.team) return ;
        wx.navigateTo({
          url: '/pages/reserve/team/index',
        })
    },
    reserveRecord(){
        wx.navigateTo({
          url: '/pages/reserve/record/index',
        })
    }
})